//
//  SQLManager.swift
//  Scaner
//
//  Created by liyahao on 2025/4/14.
//

import SQLite
import Foundation

struct SQLManager {
    static var share = SQLManager()
    var bundle: SQLiteQuery?
    let local: SQLiteQuery
    
    init() {
        // bundle不一定有
        if let bundle = Bundle.main.path(forResource: "data", ofType: "sqlite") {
            self.bundle = SQLiteQuery(dbPath: bundle)
        }
        
        let homePath = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0]
        self.local = SQLiteQuery(dbPath: homePath.appendingPath("datas.sqlite"))
        
//        createTables()
    }
    
    func createTables() {
        let models: [SQLProtocol.Type] = [AudioFiles.self, ScanFiles.self]
        models.forEach { $0.createDB() }
    }
}
